/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jpa.facade;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import jpa.entities.FuncaoPaciente;

/**
 *
 * @author issao
 */
@Stateless
public class FuncaoPacienteFacade extends AbstractFacade<FuncaoPaciente> {
    @PersistenceContext(unitName = "IMOApp-ejbPU")
    private EntityManager em;

    protected EntityManager getEntityManager() {
        return em;
    }

    public FuncaoPacienteFacade() {
        super(FuncaoPaciente.class);
    }
    
    public List<FuncaoPaciente> buscaFuncaoPacienteSemDemissao(int idPaciente) {
        String ejbql = "SELECT f FROM funcao_paciente f "
                + "WHERE f.id_funcao_paciente = :idPaciente "
                + "AND f.data_termino IS NULL";
        Query query = em.createQuery(ejbql);
        query.setParameter("idPaciente", idPaciente);
        return query.getResultList();
    }
    
}
